# -*- coding:utf-8 -*-

'''
PROJECT_NAME : python_高级
file    : use_property
author  : 1032162439@qq.com
date    : 2022-11-08 11:05
IDE     : PyCharm
'''


class Hero:
    """
    英雄类
    """

    def __init__(self):
        self.__name = ''
        self.__blood = 0

    @property
    def name(self):
        return self.__name

    @name.setter
    def name(self, name: str):
        if not isinstance(name, str):
            raise TypeError('name must be a string!')
        self.__name = name

    @property
    def blood(self):
        return self.__blood

    @blood.setter
    def blood(self, blood: float):
        if not isinstance(blood, float):
            raise TypeError('blood must be a float!')
        self.__blood = blood


def test_hero():
    luban = Hero()
    luban.name = 'fa'
    luban.blood = 100

    print(f'{luban.name}----{luban.blood}')


if __name__ == '__main__':
    test_hero()
